package com.polaris.live.utils

import android.graphics.Rect
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import com.polaris.live.common.ext.dp
import com.polaris.live.common.util.AppCodeUtils

/**
 * 首页列表item的头像展示分割器
 *
 * @author Created by 半仙 on 2024/8/31/031 11:18
 */
class HomeHeadItemDecoration : RecyclerView.ItemDecoration() {

    private var shouldUpdateOffsets = true
    override fun getItemOffsets(
        outRect: Rect,
        view: View,
        parent: RecyclerView,
        state: RecyclerView.State,
    ) {
        if (shouldUpdateOffsets) {
            if (AppCodeUtils.isAR()) {
                outRect.left = -4.dp
            } else {
                outRect.right = -4.dp
            }
            if (parent.getChildAdapterPosition(view) == 0) {
                shouldUpdateOffsets = false
            }
        }
    }
}